﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraGrid.Views.Grid;

namespace QuanLyKho.PhongThanhPham
{
    public partial class Thanhpham_BienbanXH : UserControl
    {
        public Thanhpham_BienbanXH()
        {
            InitializeComponent();
            loaddata();
        }

        public void loaddata()
        {
            DataTable data = new DataTable();
            data.Columns.Add("STT");
            data.Columns.Add("MaHang");
            data.Columns.Add("GL");
            data.Columns.Add("GL1");
            data.Columns.Add("GL2");
            data.Columns.Add("TDH");
            data.Columns.Add("TDH1");
            data.Columns.Add("TDH2");
            data.Columns.Add("KN");
            data.Columns.Add("KN1");
            data.Columns.Add("KN2");
            data.Columns.Add("BT");
            data.Columns.Add("BT1");
            data.Columns.Add("BT2");
            data.Columns.Add("LTT");
            data.Columns.Add("LTT1");
            data.Columns.Add("LTT2");
            data.Columns.Add("CG");
            data.Columns.Add("CG1");
            data.Columns.Add("CG2");
            data.Columns.Add("TDT");
            data.Columns.Add("TDT1");
            data.Columns.Add("TDT2");
            data.Columns.Add("LH");
            data.Columns.Add("LH1");
            data.Columns.Add("LH2");
            data.Columns.Add("Tong");
            data.Rows.Add("", "", "S", "M", "L", "S", "M", "L", "S", "M", "L", "S", "M", "L", "S", "M",
                "L", "S", "M", "L", "S", "M", "L", "S", "M", "L");
            //for (int i = 0; i < 12; i++)
            //{
            //    data.Rows.Add(i, i, i, i, i);
            //}
            gridXuatHang.DataSource = data;
            gvXuatHang.OptionsView.AllowCellMerge = true;
            //RepositoryItemComboBox rc = new RepositoryItemComboBox();
            //rc.Items.AddRange(new object[] { "0234", "1adsf", "2asdf", "3dfgf" });
            //rc.Items.Add("");
            //gridXuatHang.ForceInitialize();
            //gvXuatHang.Columns[1].ColumnEdit = rc;
        }

        private void gvXuatHang_CellMerge(object sender, DevExpress.XtraGrid.Views.Grid.CellMergeEventArgs e)
        {
            GridView view = sender as GridView;
            try
            {
                if ((e.Column.FieldName == "MaHang"))
                {
                    int value1 = Convert.ToInt32(view.GetRowCellValue(e.RowHandle1, e.Column));
                    int value2 = Convert.ToInt32(view.GetRowCellValue(e.RowHandle2, e.Column));

                    e.Merge = (value1 == value2);
                    e.Handled = true;
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        //private void dataGridViewX1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        //{
        //    if (e.Control is DataGridViewComboBoxEditingControl)
        //    {
        //        ((ComboBox)e.Control).DropDownStyle = ComboBoxStyle.DropDown;
        //        ((ComboBox)e.Control).AutoCompleteSource = AutoCompleteSource.ListItems;
        //        ((ComboBox)e.Control).AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
        //    }
        //}
    }
}
